const app = getApp();
let tool = require('../../../utils/tool.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    flag2: 5,
    noticeId:0,
    content:'',//上课内容
    type:'',//单词\阅读
    z_judge_content:'',//评价内容
    name:'',
    time:'',
    long:'',//总时长
    tips:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.data!=""){
      this.setData({
          noticeId:options.data,
      })
      this.getData();
    }
  console.log(options);

  },
    getData:function(){
        let that=this;
        let paramArr = {
            // access_token:app.globalData.access_token,
            access_token: app.globalData.studentInfo.access_token?app.globalData.studentInfo.access_token:app.globalData.access_token,

            ['id']:Number(this.data.noticeId)
        }
        let rs = tool.getSign(paramArr, app.globalData.key); //返回 bodyParam heaer sign
        let sign = rs.sign;
        let apiUrl = app.globalData.apiURL + "message/judge?sign=" + sign;
        let classPro = new Promise(
            function(resolve, reject) {
                wx.request({
                    url: apiUrl,
                    header: rs.header,
                    data: rs.bodyParam,
                    method: 'post',
                    success(res) {
                        console.log(res);

                        resolve(res);
                    }
                })
            }

        );

        let classHis = new Object();
        classPro.then(function(res) {
            if (res.data.code === 1) {
                console.log(res.data.data);
                classHis = res.data.data;

                that.setData({
                    content:classHis.content,//上课内容
                    type:classHis.type,//单词\阅读
                    z_judge_content:classHis.z_judge_content,//评价内容
                    name:classHis.name,
                    time:classHis.time,
                  long: classHis.long,//总时长
                    tips:classHis.tips.split(',')
                });
            }
        })
    },
    gotourl:function(){
      console.log('aaa')
        wx.navigateBack({
            delta: 1
        })


    },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})
